<%--
  Created by IntelliJ IDEA.
  User: zhouz
  Date: 2023/12/4
  Time: 15:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--输入名字，当失去焦点时判断：name值为zhangsan则认为则显示”此用户已占用”，输入其他名字则显示“此用户可以使用”--%>
请输入名称：<input type="text" name="name" id="name"><span id="info"></span>


<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#name").blur(function () {
            // TODO ajax请求
            // GET提交
            let url = "${pageContext.request.contextPath}/ajax/check?name=" + $("#name").val();
            $.get(url, function (resp) {
                $("#info").html(resp.message);
            });
        });
    });
</script>

</body>
</html>
